<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/29
 * Time: 17:01
 */
namespace admin {

    use admin\ctr;
    use C\lib\Db;
    use C\lib\Session;
    use C\mod\order;
    use C\mod\worker;
    use C\mod\ads;
    use C\mod\area;
    use C\mod\areaWorker;
    use C\mod\auth;
    use C\mod\workerd;
    use C\lib\Ditu;
    use C\mod\user;


    class aorder extends ctr {

        /*
         * 订单列表
         */
        public function listOrder(){
           // Session::start();
            if(isset($_SESSION['ads.id'])){
                $where=[];
                if (isset($_POST['lastId']) && trim($_POST['lastId']) != '') {
                    $lastId = trim($_POST['lastId'] + 0);
                } else {
                    $lastId = 0;
                }
                if($_POST['lastId'] == 0) {
                    $lastId = ['id','>',$lastId];
                } else {
                    $lastId = ['id','<',$lastId];
                }
                $where['lastId']=$lastId;
                if(isset($_POST['order_pid'])){
                    $where['order_pid']=$_POST['order_pid'];
                }
                if(isset($_POST['type'])){
                    $where['type']=$_POST['type'];
                }

                $list=[];
                $data=order::getList($where,[0,20]);
                if($data){
                    $list=$data;
                }
                $this->writeJson(1,['list'=>$list]);
            }
        }

        /*
         *
         *删除订单
         */
        public function delOrder(){
            if(isset($_SESSION['ads.id'])){
                if(empty($_POST['ids'])){
                    $this->writeJson(0,'请选择要删除的订单!');exit;
                }
                foreach ($_POST['ids'] as $val){
                    $del=order::delete(['id'=>$val]);
                }
                if($del){
                    $this->writeJson(1);exit;
                }else{
                    $this->writeJson(0,'删除失败!');exit;
                }
            }
        }
        /*
         * 编辑订单
         */
        public function upOrder(){
            if(isset($_SESSION['ads.id'])){
                if(empty($_POST['id'])){
                    $this->writeJson(0,'请选择要编辑的订单!');exit;
                }

            }
        }

    }
}